var o = require("../../../../../../@babel/runtime/helpers/regeneratorRuntime"), e = require("../../../../../../@babel/runtime/helpers/asyncToGenerator"), t = require("../z-paging-utils.js"), i = require("../z-paging-enum.js"), n = {
    props: {
        loadingMoreCustomStyle: {
            type: Object,
            default: function() {
                return t.u.gc("loadingMoreCustomStyle", {});
            }
        },
        loadingMoreTitleCustomStyle: {
            type: Object,
            default: function() {
                return t.u.gc("loadingMoreTitleCustomStyle", {});
            }
        },
        loadingMoreLoadingIconCustomStyle: {
            type: Object,
            default: function() {
                return t.u.gc("loadingMoreLoadingIconCustomStyle", {});
            }
        },
        loadingMoreLoadingIconType: {
            type: String,
            default: t.u.gc("loadingMoreLoadingIconType", "flower")
        },
        loadingMoreLoadingIconCustomImage: {
            type: String,
            default: t.u.gc("loadingMoreLoadingIconCustomImage", "")
        },
        loadingMoreLoadingAnimated: {
            type: Boolean,
            default: t.u.gc("loadingMoreLoadingAnimated", !0)
        },
        loadingMoreEnabled: {
            type: Boolean,
            default: t.u.gc("loadingMoreEnabled", !0)
        },
        toBottomLoadingMoreEnabled: {
            type: Boolean,
            default: t.u.gc("toBottomLoadingMoreEnabled", !0)
        },
        loadingMoreDefaultAsLoading: {
            type: [ Boolean ],
            default: t.u.gc("loadingMoreDefaultAsLoading", !1)
        },
        loadingMoreDefaultText: {
            type: [ String, Object ],
            default: t.u.gc("loadingMoreDefaultText", null)
        },
        loadingMoreLoadingText: {
            type: [ String, Object ],
            default: t.u.gc("loadingMoreLoadingText", null)
        },
        loadingMoreNoMoreText: {
            type: [ String, Object ],
            default: t.u.gc("loadingMoreNoMoreText", null)
        },
        loadingMoreFailText: {
            type: [ String, Object ],
            default: t.u.gc("loadingMoreFailText", null)
        },
        hideNoMoreInside: {
            type: Boolean,
            default: t.u.gc("hideNoMoreInside", !1)
        },
        hideNoMoreByLimit: {
            type: Number,
            default: t.u.gc("hideNoMoreByLimit", 0)
        },
        showDefaultLoadingMoreText: {
            type: Boolean,
            default: t.u.gc("showDefaultLoadingMoreText", !0)
        },
        showLoadingMoreNoMoreView: {
            type: Boolean,
            default: t.u.gc("showLoadingMoreNoMoreView", !0)
        },
        showLoadingMoreNoMoreLine: {
            type: Boolean,
            default: t.u.gc("showLoadingMoreNoMoreLine", !0)
        },
        loadingMoreNoMoreLineCustomStyle: {
            type: Object,
            default: function() {
                return t.u.gc("loadingMoreNoMoreLineCustomStyle", {});
            }
        },
        insideMore: {
            type: Boolean,
            default: t.u.gc("insideMore", !1)
        },
        lowerThreshold: {
            type: [ Number, String ],
            default: t.u.gc("lowerThreshold", "100rpx")
        }
    },
    data: function() {
        return {
            M: i.Enum.More,
            loadingStatus: i.Enum.More.Default,
            loadingStatusAfterRender: i.Enum.More.Default,
            loadingMoreTimeStamp: 0,
            loadingMoreDefaultSlot: null,
            showLoadingMore: !1,
            customNoMore: -1
        };
    },
    computed: {
        zLoadMoreConfig: function() {
            return {
                status: this.loadingStatusAfterRender,
                defaultAsLoading: this.loadingMoreDefaultAsLoading,
                defaultThemeStyle: this.finalLoadingMoreThemeStyle,
                customStyle: this.loadingMoreCustomStyle,
                titleCustomStyle: this.loadingMoreTitleCustomStyle,
                iconCustomStyle: this.loadingMoreLoadingIconCustomStyle,
                loadingIconType: this.loadingMoreLoadingIconType,
                loadingIconCustomImage: this.loadingMoreLoadingIconCustomImage,
                loadingAnimated: this.loadingMoreLoadingAnimated,
                showNoMoreLine: this.showLoadingMoreNoMoreLine,
                noMoreLineCustomStyle: this.loadingMoreNoMoreLineCustomStyle,
                defaultText: this.finalLoadingMoreDefaultText,
                loadingText: this.finalLoadingMoreLoadingText,
                noMoreText: this.finalLoadingMoreNoMoreText,
                failText: this.finalLoadingMoreFailText,
                hideContent: !this.loadingMoreDefaultAsLoading && this.listRendering
            };
        },
        finalLoadingMoreThemeStyle: function() {
            return this.loadingMoreThemeStyle.length ? this.loadingMoreThemeStyle : this.defaultThemeStyle;
        },
        showLoadingMoreDefault: function() {
            return this._showLoadingMore("Default");
        },
        showLoadingMoreLoading: function() {
            return this._showLoadingMore("Loading");
        },
        showLoadingMoreNoMore: function() {
            return this._showLoadingMore("NoMore");
        },
        showLoadingMoreFail: function() {
            return this._showLoadingMore("Fail");
        },
        showLoadingMoreCustom: function() {
            return this._showLoadingMore("Custom");
        }
    },
    methods: {
        pageReachBottom: function() {
            !this.useChatRecordMode && this._onLoadingMore("toBottom");
        },
        doLoadMore: function(o) {
            this._onLoadingMore(o);
        },
        _checkScrolledToBottom: function(o) {
            var e = this, i = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
            -1 === this.cacheScrollNodeHeight ? this._getNodeClientRect(".zp-scroll-view").then(function(t) {
                if (t) {
                    var i = t[0].height;
                    e.cacheScrollNodeHeight = i, o - i <= e.finalLowerThreshold && e._onLoadingMore("toBottom");
                }
            }) : o - this.cacheScrollNodeHeight <= this.finalLowerThreshold ? this._onLoadingMore("toBottom") : o - this.cacheScrollNodeHeight <= 500 && !i && t.u.delay(function() {
                e._getNodeClientRect(".zp-scroll-view", !0, !0).then(function(o) {
                    e.oldScrollTop = o[0].scrollTop;
                    var t = o[0].scrollHeight - e.oldScrollTop;
                    e._checkScrolledToBottom(t, !0);
                });
            }, 150, "checkScrolledToBottomDelay");
        },
        _onLoadingMore: function() {
            var o = this, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "click";
            if (this.isIos && "toBottom" === e && !this.scrollToBottomBounceEnabled && this.scrollEnable && (this.scrollEnable = !1, 
            this.$nextTick(function() {
                o.scrollEnable = !0;
            })), this.$emit("scrolltolower", e), ("toBottom" !== e || this.toBottomLoadingMoreEnabled && !this.useChatRecordMode) && !(this.refresherOnly || !this.loadingMoreEnabled || this.loadingStatus !== i.Enum.More.Default && this.loadingStatus !== i.Enum.More.Fail || this.loading || this.showEmpty)) {
                if (!this.isIos && !this.refresherOnly && !this.usePageScroll) {
                    var n = t.u.getTime();
                    if (this.loadingMoreTimeStamp > 0 && n - this.loadingMoreTimeStamp < 100) return void (this.loadingMoreTimeStamp = 0);
                }
                this._doLoadingMore();
            }
        },
        _doLoadingMore: function() {
            var o = this;
            this.pageNo >= this.defaultPageNo && this.loadingStatus !== i.Enum.More.NoMore && (this.pageNo++, 
            this._startLoading(!1), this.isLocalPaging ? this._localPagingQueryList(this.pageNo, this.defaultPageSize, this.localPagingLoadingTime, function(e) {
                o.completeByTotal(e, o.totalLocalPagingList.length);
            }) : (this._emitQuery(this.pageNo, this.defaultPageSize, i.Enum.QueryFrom.LoadingMore), 
            this._callMyParentQuery()), this.loadingType = i.Enum.LoadingType.LoadingMore);
        },
        _preCheckShowNoMoreInside: function(o, e, t) {
            var n = this;
            this.loadingStatus === i.Enum.More.NoMore && this.hideNoMoreByLimit > 0 && o.length ? this.showLoadingMore = o.length > this.hideNoMoreByLimit : this.loadingStatus === i.Enum.More.NoMore && this.hideNoMoreInside && o.length || this.insideMore && !1 !== this.insideOfPaging && o.length ? (this.$nextTick(function() {
                n._checkShowNoMoreInside(o, e, t);
            }), this.insideMore && !1 !== this.insideOfPaging && o.length && (this.showLoadingMore = o.length)) : this.showLoadingMore = o.length;
        },
        _checkShowNoMoreInside: function(t, i, n) {
            var a = this;
            return e(o().mark(function e() {
                var r, l, s, d, g;
                return o().wrap(function(o) {
                    for (;;) switch (o.prev = o.next) {
                      case 0:
                        if (o.prev = 0, o.t0 = i, o.t0) {
                            o.next = 6;
                            break;
                        }
                        return o.next = 5, a._getNodeClientRect(".zp-scroll-view");

                      case 5:
                        o.t0 = o.sent;

                      case 6:
                        if (r = o.t0, !a.usePageScroll) {
                            o.next = 11;
                            break;
                        }
                        r && (l = r[0].top + r[0].height, a.insideOfPaging = l < a.windowHeight, a.hideNoMoreInside && (a.showLoadingMore = !a.insideOfPaging), 
                        a._updateInsideOfPaging()), o.next = 20;
                        break;

                      case 11:
                        if (o.t1 = n, o.t1) {
                            o.next = 16;
                            break;
                        }
                        return o.next = 15, a._getNodeClientRect(".zp-paging-container-content");

                      case 15:
                        o.t1 = o.sent;

                      case 16:
                        s = o.t1, d = s ? s[0].height : 0, g = r ? r[0].height : 0, a.insideOfPaging = d < g, 
                        a.hideNoMoreInside && (a.showLoadingMore = !a.insideOfPaging), a._updateInsideOfPaging();

                      case 20:
                        o.next = 25;
                        break;

                      case 22:
                        o.prev = 22, o.t2 = o.catch(0), a.insideOfPaging = !t.length, a.hideNoMoreInside && (a.showLoadingMore = !a.insideOfPaging), 
                        a._updateInsideOfPaging();

                      case 25:
                      case "end":
                        return o.stop();
                    }
                }, e, null, [ [ 0, 22 ] ]);
            }))();
        },
        _showLoadingMore: function(o) {
            return !!(this.showLoadingMoreWhenReload || (this.loadingStatus !== i.Enum.More.Default || this.nShowBottom) && this.realTotalData.length) && (!(!(this.showLoadingMoreWhenReload && !this.isUserPullDown && this.loadingStatus === i.Enum.More.Loading || this.showLoadingMore) || !(this.loadingMoreEnabled || this.showLoadingMoreWhenReload && !this.isUserPullDown && this.loadingStatus === i.Enum.More.Loading) || this.refresherOnly) && ((!this.useChatRecordMode || "Loading" === o) && (!!this.zSlots && ("Custom" === o ? this.showDefaultLoadingMoreText && !(this.loadingStatus === i.Enum.More.NoMore && !this.showLoadingMoreNoMoreView) : this.loadingStatus === i.Enum.More[o] && this.zSlots["loadingMore".concat(o)] && ("NoMore" !== o || this.showLoadingMoreNoMoreView)))));
        }
    }
};

exports.loadMoreModule = n;